package com.mlming.springboot.service.impl;

import com.mlming.springboot.dao.CommentMapper;
import com.mlming.springboot.enums.ResponseEnum;
import com.mlming.springboot.pojo.Comment;
import com.mlming.springboot.service.CommentService;
import com.mlming.springboot.vo.ResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;

    @Override
    public List<Comment> getAllCommentList() {
        List<Comment> comments = commentMapper.selectAll();
        return comments;
    }

    @Override
    public List<Comment> getCommentListOfCard(Integer cardId) {
        List<Comment> comments = commentMapper.selectByCardId(cardId);
        return null;
    }

    @Override
    public ResponseVo addComment(Comment comment) {
        int res = commentMapper.insertSelective(comment);
        if(res == 0) return ResponseVo.error(ResponseEnum.ERROR);
        return ResponseVo.success();
    }
}
